<?php
/**
 * Classe que faz as consultas SQL para a Categoria
 * 
 * @author Rafael Mitsuo Moriya <rafaumsurfista@gmail.com>
 * @version 1.0 2009-02-11 00:00:00
 * @package RH
 * @subpackage classes_banco
 * @access public
 * @see Listagem
 */
class professordisciplina extends Zend_Db_Table_Abstract 
{
	protected $_table = "professordisciplina";
	protected $_primary = "idprofessordisciplina";
	
	/*
	 * Default
	 */
	
	public function salvar($array)
	{
		if(isset($array['idprofessordisciplina'])){
			$this->update($array,"idprofessordisciplina = '{$array['idprofessordisciplina']}'");
			return $array['idprofessordisciplina'];
		}else{
			return $this->insert($array);
		}
	}
	
	public function pegaprofessordisciplina($idprofessordisciplina)
	{
		$array = $this->find($idprofessordisciplina);
		return $array[0];
	}
	
	public function listar()
	{
		return $this->fetchAll();
	}
	
	public function listarporturma($idturma)
	{
		$array = array();
		
		$sql = $this->_db->select()->from("professordisciplina")->joinInner("professor","professor.idprofessor = professordisciplina.idprofessor")->where("idturma = '{$idturma}'");
		
		foreach($this->_db->fetchAll($sql) as $key){
			$array[$key['iddisciplina']]['professor'] = $key['professor'];
			$array[$key['iddisciplina']]['idprofessordisciplina'] = $key['idprofessordisciplina'];
		}
		return $array;
	}
	
	public function pegaporturmadisciplina($idturma,$iddisciplina)
	{
		$array = $this->fetchAll("idturma = '{$idturma}' AND iddisciplina = '{$iddisciplina}'");
		
		return @$array[0];
	}
	
}
?>